<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: green;
        }
    </style>
</head>
<body>
    <!-- div本身就是一个对象 class/onclick等等 都是该对象的属性 -->
    <div class="box" onclick="foo()">div1</div>
    <button onclick="bar()">按钮</button>

    <script>
        function foo() {
            alert('hello world');
        }
        function bar() {
            foo();
        }
    </script>
</body>
</html>